import store from "../../redux/store"
import { useEffect, useState } from 'react'
import { Button } from 'antd'





function Mine() {

  const [count, setCount] = useState(store.getState().countReducer);
  
  const increment = () => {
    store.dispatch({ type: "increment", data: 1 })
  }

  const decrement = () => {
    store.dispatch({ type: "decrement", data: 1 })
  }
  useEffect(() => {
    store.subscribe(() => {
      setCount(store.getState().countReducer)
    })
  })

  return (
    <>
      <h2> mine page</h2>

      <div>
        {store.getState().goodsReducer.name}
        <h1>当前求和为：{count}</h1>&nbsp;&nbsp;

        <Button type="primary" onClick={increment}>increment</Button> &nbsp;

        <Button onClick={decrement}>decrement</Button>&nbsp;

      </div>

    </>
  )
}



export default Mine